/*初始化*/

#include "threadPool.h"

int threadPoolInit(threadPool_t *pthreadPool, int threadNum)
{
    bzero(pthreadPool, sizeof(threadPool_t));
    
    // 为tid数组申请内存
    pthreadPool->threadNum = threadNum;
    pthreadPool->tidArr = (pthread_t *)calloc(threadNum, sizeof(pthread_t));

    // 初始化任务队列当中的锁和条件变量
    // 头指针尾指针及大小的初始化在bzero的时候就已经做好了
    pthread_mutex_init(&pthreadPool->taskQueue.mutex, NULL);
    pthread_cond_init(&pthreadPool->taskQueue.cond, NULL);

    return 0;
}